//
//  XiaoXiReciveCell.m
//  SanYiTeaching
//
//  Created by 李文强 on 2019/4/30.
//  Copyright © 2019 SanYi. All rights reserved.
//

#import "XiaoXiReciveCell.h"

@implementation XiaoXiReciveCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    if ([super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        [self initSubView];
        [self layout];
    }
    return self;
}
- (void)initSubView{
    [self addSubview:self.baseView];
    [_baseView addSubview:self.titleLabel];
    [_baseView addSubview:self.classLabel];
    [_baseView addSubview:self.dateLabel];
    [_baseView addSubview:self.otherButton];
}
- (void)layout{
    [_baseView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self.mas_centerX);
        make.width.equalTo(@589);
        make.height.equalTo(@75);
        make.centerY.equalTo(self.mas_centerY);
    }];
    [_titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self->_baseView.mas_left).offset(10);
        make.right.equalTo(self->_baseView.mas_centerX);
        make.top.equalTo(self->_baseView.mas_top).offset(10);
        make.bottom.equalTo(self->_baseView.mas_centerY);
    }];
    [_classLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self->_titleLabel.mas_left);
        make.width.equalTo(@120);
        make.top.equalTo(self->_titleLabel.mas_bottom);
        make.bottom.equalTo(self->_baseView.mas_bottom);
    }];
    [_dateLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self->_baseView.mas_centerX);
        make.left.equalTo(self->_classLabel.mas_right);
        make.top.equalTo(self->_titleLabel.mas_bottom);
        make.bottom.equalTo(self->_baseView.mas_bottom);
    }];
    [_otherButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self->_baseView.mas_right).offset(-10);
        make.width.equalTo(@21);
        make.top.equalTo(self->_baseView.mas_top).offset(10);
        make.height.equalTo(@10);
    }];
}
- (UIView *)baseView{
    if (!_baseView) {
        UIView *view = [[UIView alloc]init];
        view.backgroundColor = [UIColor whiteColor];
        view.layer.cornerRadius = 5;
        view.layer.masksToBounds = YES;
        view.layer.borderColor = LINCOLOR.CGColor;
        view.layer.borderWidth = 1;
        _baseView = view;
    }
    return _baseView;
}
- (UILabel *)titleLabel{
    if (!_titleLabel) {
        UILabel *label = [[UILabel alloc]init];
        label.text = @"名字";
        label.font = [UIFont systemFontOfSize:14];
        label.textColor = [UIColor darkGrayColor];
        label.textAlignment = 0;
        _titleLabel = label;
    }
    return _titleLabel;
}
- (UILabel *)classLabel{
    if (!_classLabel) {
        UILabel *label = [[UILabel alloc]init];
        label.text = @"英语VIP二班";
        label.font = [UIFont systemFontOfSize:14];
        label.textColor = TITLECOLOR;
        label.textAlignment = 0;
        _classLabel = label;
    }
    return _classLabel;
}
- (UILabel *)dateLabel{
    if (!_dateLabel) {
        UILabel *label = [[UILabel alloc]init];
        label.text = @"04月02日 12:23";
        label.font = [UIFont systemFontOfSize:14];
        label.textColor = TITLECOLOR;
        label.textAlignment = 0;
        _dateLabel = label;
    }
    return _dateLabel;
}
- (UIButton *)otherButton{
    if (!_otherButton) {
        UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
        [button setImage:[UIImage imageNamed:@"menu_buke"] forState:UIControlStateNormal];
        [button addTarget:self action:@selector(addClick) forControlEvents:UIControlEventTouchUpInside];
        _otherButton = button;
    }
    return _otherButton;
}
- (void)addClick{
    _alertView = [[XiaoXiAlertButtonView alloc]initWithFrame:CGRectMake(0, 0, 100, 60)];
    _alertView.userInteractionEnabled = YES;
    [_baseView addSubview:self.alertView];
    [_alertView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(@0).offset(-10);
        make.top.equalTo(@5);
        make.bottom.equalTo(@0).offset(-5);
        make.width.equalTo(@80);
    }];
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
